﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace IFServerDLL.DB
{
    [DataContract]
    public class MyDBData
    {
        public MyDBData()
        {

        }
        public MyDBData(HCY.CTP.DBShangZheng.DBTableMarketDataZi zi, HCY.CTP.DBShangZheng.DBTableMarketData data)
        {

            
            OpenPrice = zi.开盘价;
            YesterdayClosePrice = zi.昨收盘;
            YesterdaySettlementPrice = zi.昨结算;
            RiseLimitPrice = zi.涨停价;
            FallLimitPrice = zi.跌停价;
            YesterdayVolume = zi.昨持仓;
            Instrument = zi.合约;

            MyServerTime = data.服务器时间;
            MarketTime = data.报单时间;
            HighPrice = data.最高价;
            LowPrice = data.最低价;
            SellPrice = data.卖价;
            BuyPrice = data.买价;
            BuyVolume = data.买量;
            SellVolume = data.卖量;
            NewPrice = data.最新价;
            AvgPrice = Math.Round(data.均价 / 300m, 1);
            SettlementVolume = data.持仓量;
            TradeVolume = data.成交量;



        }
        public int GetTimePct()
        {
            return Convert.ToInt32(MyServerTime / 658);
        }
        [DataMember]
        public decimal OpenPrice { get; set; }
         [DataMember]
        public decimal YesterdayClosePrice { get; set; }
         [DataMember]
        public decimal YesterdaySettlementPrice { get; set; }
         [DataMember]
        public decimal RiseLimitPrice { get; set; }
         [DataMember]
        public decimal FallLimitPrice { get; set; }
         [DataMember]
        public int YesterdayVolume { get; set; }
         [DataMember]
        public string Instrument { get; set; }


         [DataMember]
        public int MyServerTime { get; set; }
         [DataMember]
        public decimal HighPrice { get; set; }
         [DataMember]
        public decimal LowPrice { get; set; }
         [DataMember]
        public decimal SellPrice { get; set; }
         [DataMember]
        public decimal BuyPrice { get; set; }
         [DataMember]
        public decimal NewPrice { get; set; }
         [DataMember]
        public decimal AvgPrice { get; set; }
         [DataMember]
        public int SellVolume { get; set; }
         [DataMember]
        public int BuyVolume { get; set; }
         [DataMember]
        public int SettlementVolume { get; set; }
         [DataMember]
        public int TradeVolume { get; set; }
         [DataMember]
        public DateTime MarketTime { get; set; }

    }
}
